package com.nineclock.sign.controller;

import com.nineclock.common.entity.PageResult;
import com.nineclock.common.entity.Result;
import com.nineclock.sign.SignControllerApi;
import com.nineclock.sign.dto.SignPCListDTO;
import com.nineclock.sign.service.SignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/sign")
public class SignController implements SignControllerApi {
    @Autowired
    private SignService signService;

    /**
     * 导出签到列表
     * @param startTime
     * @param endTime
     * @return
     */
    @Override
    @GetMapping("/export")
    public void exportData(String startTime, String endTime) throws IOException {
        signService.exportData(startTime, endTime);
    }

    @GetMapping("/sign")
    public Result<PageResult> querySignData(String startTime, String endTime,
                                            @RequestParam(value = "page",defaultValue = "1") Integer page,
                                            @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize) {

        PageResult<List<SignPCListDTO>> pageResult = signService.querySignData(startTime, endTime, page, pageSize);
        return Result.success(pageResult);
    }
}
